package com.JustTest;

import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.concurrent.TimeUnit;

public class Client {

    public static void main(String[] args) throws IOException {
       new Client().start();
    }

    public void start() throws IOException {
        Socket s = new Socket("127.0.0.1",4444);
        new Thread(new MyRunnalble(s.getOutputStream())).start();
        new Thread(new MyRunnalble(s.getOutputStream())).start();
    }

    class MyRunnalble implements Runnable{
        OutputStream os;

        public MyRunnalble(OutputStream os) {
            this.os = os;
        }

        @Override
        public void run() {
            while(true){
                try {
                    os.write(3);
                    TimeUnit.SECONDS.sleep(2);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
